package com.jyw.business.ins.controller;

import com.jyw.business.ins.domain.vo.web.HomeInsToDoVO;
import com.jyw.business.ins.domain.vo.web.HomeMineRectifyVO;
import com.jyw.business.ins.domain.vo.web.HomeMineTaskVO;
import com.jyw.business.ins.service.IInsTaskService;
import com.jyw.business.obstacles.domain.vo.web.HomeMineServerVO;
import com.jyw.common.core.domain.CommonResult;
import com.jyw.common.utils.DateUtils;
import com.jyw.system.domain.dto.BaseTimeDto;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@Api(tags = "首页")
@RestController
@RequestMapping("/ins/home")
public class InsHomeController {

    @Resource
    private IInsTaskService taskService;

    @GetMapping("task")
    @ApiOperation("我的巡检")
    public CommonResult<List<HomeMineTaskVO>> mineTask(BaseTimeDto baseTimeDto){
        if (!ObjectUtils.isEmpty(baseTimeDto)) {
            baseTimeDto.setEndDate(DateUtils.toDateLastTime(baseTimeDto.getEndDate()));
        }
        return CommonResult.success(taskService.mineTask(baseTimeDto));
    }

    @GetMapping("rectify")
    @ApiOperation("我的整改")
    public CommonResult<List<HomeMineRectifyVO>> mineRectify(BaseTimeDto baseTimeDto){
        if (!ObjectUtils.isEmpty(baseTimeDto)) {
            baseTimeDto.setEndDate(DateUtils.toDateLastTime(baseTimeDto.getEndDate()));
        }
        return CommonResult.success(taskService.mineRectify(baseTimeDto));
    }

    @GetMapping("todo")
    @ApiOperation("我的待办事项(巡检)")
    public CommonResult<HomeInsToDoVO> todo(){
        return CommonResult.success(taskService.todo());
    }
}
